Page({
  data: {
    latitude: 34.223, // 纬度
    longitude: 108.952, // 经度
    markers: [
      {
        id: 1,
        latitude: 34.223,
        longitude: 108.952,
        iconPath: "/pages/images/1.gif",
        width: 50,
        height: 50
      }
    ],
    polyline: [],
    circles: []
  },
  onLoad: function () {
    wx.authorize({
      scope: 'scope.userLocation',
      success() {
        console.log('用户已授权位置信息');
      },
      fail() {
        console.error('用户拒绝授权位置信息');
        wx.showModal({
          title: '提示',
          content: '需要授权位置信息才能使用地图功能',
          showCancel: false
        });
      }
    });
  },
  onReady: function () {
    let map = wx.createMapContext('map');
    map.moveToLocation({
      success: () => {
        console.log('地图定位成功');
      },
      fail: (err) => {
        console.error('地图定位失败', err);
      }
    });
  }
});